# Reference: <https://postmarketos.org/devicepkg>
# Maintainer: Nikita Travkin <nikitos.tr@gmail.com>
# Co-Maintainer: Minecrell <minecrell@minecrell.net>
pkgname=device-wileyfox-crackling
pkgdesc="Wileyfox Swift"
pkgver=9
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="postmarketos-base mkbootimg linux-postmarketos-qcom-msm8916
	 soc-qcom-msm8916 soc-qcom-msm8916-rproc"
makedepends="devicepkg-dev"
source="
	deviceinfo
	modules-initfs
	10-crackling-proximity.rules
	"
subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
"
_pmb_select="soc-qcom-msm8916-rproc"

# Backwards compatibility for old kernel variant subpackages
replaces="$pkgname-kernel-mainline $pkgname-kernel-mainline-modem"
for pkg in $replaces; do provides="$provides $pkg=$pkgver-r$pkgrel"; done

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname

	install -D -m644 "$srcdir"/10-crackling-proximity.rules \
		"$pkgdir"/usr/lib/udev/rules.d/10-crackling-proximity.rules
}

nonfree_firmware() {
	pkgdesc="GPU/WiFi/BT/Modem/Video firmware"
	depends="firmware-qcom-adreno-a300 msm-firmware-loader
		 firmware-wileyfox-crackling-wcnss-nv firmware-wileyfox-crackling-venus"
	mkdir "$subpkgdir"
}

sha512sums="
9d3ed4562e48c6ec484a4a6faf7a836c48c18fabf5ccbbe718b80df168a8b8706a962f1b2bd76bc1adbbb5bf5043be32678850884c5baf779684de414619896b  deviceinfo
31f926acffed502edca7d6a26c97c197970b842122df42a1ea5c63f2707b4375465eae77a754f5d58f556f55e1f5f421af21a92ca6165a3a4bacf55c5fbf7faf  modules-initfs
a845e860cf43e58818bbffda62a9514e9a24527e14c485dd10944587b29dbf5864a1d3ec17d219c342512fac4bd6c25f5f0f4efb8883b8f383a79846759318ee  10-crackling-proximity.rules
"
